import java.util.Random;
import java.util.Scanner;

public class GuessNumber {
public static int sc(){

    return (int)(Math.random()*100+1);
}
public static void guessFunction(){
    Scanner scanner = new Scanner(System.in);
    int count = 0;
    int sc = sc();
    while (count<7) {
        System.out.println((count+1)+".请输入你要猜的数字：");
        int guess = scanner.nextInt();
        if (guess == sc) {
            System.out.println("恭喜猜对了");
            System.out.println("是否重玩(0:重玩/其他数字：游戏结束)");
            int playAgain = scanner.nextInt();
            if (playAgain == 0){
                count = -1;
                sc = sc();
            }else {
                System.out.println("游戏结束");
                break;
            }

        } else if (guess < sc) {
            System.out.println("猜小了");
        } else {
            System.out.println("猜大了");
        }
        count++;
        if (count==7){
            System.out.println("是否重玩(0:重玩/其他数字：游戏结束)");
            int playAgain = scanner.nextInt();
            if (playAgain == 0){
                count = 0;
                sc = sc();
            }else {
                System.out.println("游戏结束");
                break;
            }
        }
    }
}

    public static void main(String[] args) {
    guessFunction();


    }
}
